package;

import cli.*;
import common.Main;
import common.Constants.*;

class Game {
    static var keys = [
        // Esc
        27 => KEY_EXIT,

        // qwe
        // a d
        // zsx
        113 => KEY_UPLEFT,
        119 => KEY_UP,
        101 => KEY_UPRIGHT,
        97  => KEY_LEFT,
        100 => KEY_RIGHT,
        112 => KEY_DOWNLEFT,
        115 => KEY_DOWN,
        120 => KEY_DOWNRIGHT,
    ];

    public static function main() {
        var grid = new Grid();
        var loop = new Main(grid);

        var key: Null<Int> = null;
        while (true) {
            loop.update(key);
            grid.print();

            var char: Int = Sys.getChar(false);
            key = keys[char];

            if (key == KEY_EXIT) {
                Sys.exit(0);
            }
        }
    }
}
